/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lolbuilder.calculation;

import java.util.ArrayList;
import lolbuilder.Champions.Impl.GenericChamp;
import lolbuilder.Items.Interf.ItemsSuper;
import lolbuilder.build.Build;

/**
 *
 * @author maximveron
 */
public class BuildOrderCalculator extends Thread {
    Build toOrder=new Build();
    public Build result=new Build();

    public BuildOrderCalculator(Build b) {
        toOrder.items.addAll(b.items);
    }


    @Override
    public void run() {
        ArrayList<ItemsSuper> cur=new ArrayList<ItemsSuper>();
        cur.addAll(toOrder.items);
        while (result.items.size()<toOrder.items.size()) {
            Build tmp=new Build();
            tmp.items.addAll(result.items);
            float bestDps=0;
            int index=0;
            for (int k=0;k<cur.size();k++) {
                ItemsSuper tmpItem=cur.get(k);
                tmp.items.add(tmpItem);
                GenericChamp c=new GenericChamp();
                tmp.applyThisBuild(c);
                c.calculateAllDatas();
                if (c.dpsOver100sec>bestDps) {
                    bestDps=c.dpsOver100sec;
                    index=k;
                }
                tmp.items.remove(tmpItem);
            }
            result.items.add(cur.get(index));
            cur.remove(index);
        }
    }
}
